﻿using System.Collections.ObjectModel;

namespace DeltaGroup.WheelOfJeopardy.UI.ViewModel
{
    using System.Collections.Generic;
    using System.Linq;

    using DeltaGroup.WheelOfJeopardy.GameManager;
    using DeltaGroup.WheelOfJeopardy.Model;

    public class NormalRoundViewModel : BaseViewModel
    {
        #region Fields

        private bool _debugMode;

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="NormalRoundViewModel"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="round">The round.</param>
        /// <param name="contestants">The contestants.</param>
        /// <param name="debugMode">if set to <c>true</c> [debug mode].</param>
        public NormalRoundViewModel(string name, NormalRound round, List<Contestant> contestants, bool debugMode)
        {
            Name = name;
            Contestants = contestants;
            Round = round;
            DebugMode = debugMode;
            Categories = round.Categories.Select(x => new CategoryViewModel(x)).ToList();
            Messages = new ObservableCollection<string>();
        }

        #endregion Constructors

        #region Properties

        /// <summary>
        /// Gets or sets the categories.
        /// </summary>
        /// <value>The categories.</value>
        public List<CategoryViewModel> Categories
        {
            get; set;
        }

        /// <summary>
        /// Gets or sets the contestants.
        /// </summary>
        /// <value>The contestants.</value>
        public List<Contestant> Contestants
        {
            get; set;
        }

        /// <summary>
        /// Gets the current contestant.
        /// </summary>
        /// <value>The current contestant.</value>
        public Contestant CurrentContestant
        {
            get
            {
                return Contestants.First(x => x.IsPlaying);
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [debug mode].
        /// </summary>
        /// <value><c>true</c> if [debug mode]; otherwise, <c>false</c>.</value>
        public bool DebugMode
        {
            get { return _debugMode; }
            set
            {
                _debugMode = value;
                FirePropertyChanged("DebugMode");
            }
        }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        /// <value>The name.</value>
        public string Name
        {
            get; set;
        }

        /// <summary>
        /// Gets or sets the round.
        /// </summary>
        /// <value>The round.</value>
        public NormalRound Round
        {
            get; set;
        }

        public ObservableCollection<string> Messages { get; set; }

        #endregion Properties
    }
}